# cbox

[![Build Status](https://secure.travis-ci.org/garbados/cbox.png?branch=update)](http://travis-ci.org/garbados/cbox)
[![Coverage Status](https://coveralls.io/repos/github/garbados/cbox/badge.svg?branch=update)](https://coveralls.io/r/garbados/cbox)
[![NPM version](https://badge.fury.io/js/cbox.png)](http://badge.fury.io/js/cbox)

N.B. The current "up-to-date" branch is called "update".

Maps a file directory into CouchDB attachments, and then pushes, pulls, or syncs with a CouchDB instance. Designed to run forever, consume minimal network traffic, and preserve file history while respecting deletions.

It's like an open-source Dropbox.

## Installation

It's written in [node](https://nodejs.org) so you'll need [npm](https://www.npmjs.com/). Then:

    npm install -g cbox
    cbox # prints commands, usage

As an example, to continually sync a local directory to a CouchDB instance:

    cbox --source {folder} --target {url} --watch

That's it! cbox will watch files in the `source` folder and push them to the `target` database whenever they change. To stop syncing, stop the process by pressing `Ctrl-C` or the like. To save that command for the future, use `save`:

    cbox save --source {folder} --target {url} --watch
    cbox all # runs all saved jobs

To synchronize files between the source and the target, so that any changes to either are reflected in the other, use `--reciprocate`:

    cbox --source {folder} --target {url} --reciprocate

cbox uses adapters to interpret source and target arguments. Arguments that don't start with a protocol will be treated as absolute paths to local directories; arguments starting with 'http' will be interpreted as the URL of a CouchDB database; arguments starting with 'ftp' or anything else will throw `NOTIMPLEMENTED` until we, y'know, implement them.

For more help, just run `cbox` without any arguments. It'll print detailed usage information.

## Running on Startup

N.B. These instructions are for *nix systems, like Linux and Mac OS X

Using [forever](https://github.com/nodejitsu/forever) and `cron`, you can set cbox to run on a regular basis. Like this:

    npm install -g forever
    echo '@reboot' `which node` `which forever` '--minUptime 1' `which cbox` '--log info' | crontab

That'll run all saved jobs whenever your computer starts. If cbox fails, `forever` will restart it.

## Config

By default, jobs are saved to `~/.cbox.conf.json`. It's just JSON, so you can edit it as you please. If it becomes invalid JSON, cbox will get angry. Here's an example config file:

    [
      {
        "source": "~/Pictures",
        "target": "http://localhost:5984/pictures",
        "watch": true,
        "reciprocate": false
      }
    ]

## Tests

    git clone git@github.com:garbados/cbox.git
    cd cbox
    npm test

## License

Fuck you, pay me.

What's that mean? Well, since you're reading this, you can read this project's source code. Congrats! If you want to use this project, even just to run on your personal computer, talk to me. Find my email in `package.json`, hit me up, and get ready to negotiate price.

Survival isn't free and neither is my software.
